import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout/index.js'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
	{
		path: '/redirect',
		component: Layout,
		hidden: true,
		children: [
			{
				path: '/redirect/:path*',
				component: () => import('@/views/redirect/index')
			}
		]
	},
	{
		path: '/login',
		component: () => import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/auth-redirect',
		component: () => import('@/views/login/auth-redirect'),
		hidden: true
	},
	{
		path: '/404',
		component: () => import('@/views/error-page/404'),
		hidden: true
	},
	{
		path: '/401',
		component: () => import('@/views/error-page/401'),
		hidden: true
	},
	{
		path: '/guide',
		component: Layout,
		redirect: '/guide/index',
		hidden: true,
		children: [
			{
				path: 'index',
				component: () => import('@/views/guide/index'),
				name: 'Guide',
				meta: { title: 'Guide', icon: 'guide', noCache: true }
			}
		]
	},
];
// .concat(testcoms)

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
	{
		path: '/dashboard',
		component: () => import('@/views/RCIM-information/index.vue'),
		name: "dashboard",
		meta: { title: '信息舱', icon: 'iconfont iconFill' }
	},

	// {
	// 	path: '/dashboard',
	// 	component: Layout,
	// 	redirect: '/dashboard/dashboard',
	// 	children: [
	// 		{
	// 			path: '/dashboard',
	// 			component: () => import('@/views/dashboard/index'),
	// 			name: '首页',
	// 			meta: { title: '首页', icon: 'dashboard', affix: true }
	// 		}
	// 	]
	// },
	{
		path: '/RCIM-nuclearSafetyRanking',
		component: Layout,
		children: [
			{
				path: '/RCIM-nuclearSafetyRanking',
				component: () => import('@/views/RCIM-nuclearSafetyRanking/index'),
				name: '核安全排名',
				meta: { title: '核安全排名', icon: 'iconfont iconpaiming' }
			}
		]
	},
	{
		path: '/RCIM-historyData',
		component: Layout,
		redirect: '/RCIM-historyData/integrated-data',
		meta: { title: '历史数据', icon: 'iconfont iconLogManagementPSOA' },
		isChildren: true,
		children: [
			{
				path: '/integrated-data',
				component: () => import('@/views/RCIM-historyData/integrated-data'),
				name: '综合数据',
				meta: { title: '综合数据' }
			},
			{
				path: '/video-data',
				component: () => import('@/views/RCIM-historyData/video-data'),
				name: '视频数据',
				meta: { title: '视频数据' }
			}
		]
	},
	{
		path: '/RCIM-historyTrend',
		component: Layout,
		children: [
			{
				path: '/RCIM-historyTrend',
				component: () => import('@/views/RCIM-historyTrend/index'),
				name: '历史趋势',
				meta: { title: '历史趋势', icon: 'iconfont iconqushi' }
			}
		]
	},
	{
		path: '/RCIM-abnormalSearch',
		component: Layout,
		children: [
			{
				path: '/RCIM-abnormalSearch',
				component: () => import('@/views/RCIM-abnormalSearch'),
				name: '异常查询',
				meta: { title: '异常查询', icon: 'iconfont iconchaxun' }
			},
			{
				path: '/RCIM-abnormalHandle',
				component: () => import('@/views/RCIM-abnormalSearch/handleAbnormal'),
				hidden: true,
				name: '异常处理',
				meta: { title: '异常处理', icon: 'iconfont iconchaxun' }
			}
		]
	},
	{
		path: '/RCIM-statusChange',
		component: Layout,
		redirect: '/RCIM-statusChange/source-record',
		meta: { title: '状态变更记录', icon: 'iconfont iconai203' },
		isChildren: true,
		children: [
			{
				path: '/stock-record',
				component: () => import('@/views/RCIM-statusChange/stock-record'),
				name: '出入库记录',
				meta: { title: '出入库记录' }
			},
			{
				path: '/source-record',
				component: () => import('@/views/RCIM-statusChange/source-record'),
				name: '源状态记录',
				meta: { title: '源状态记录' }
			}

		]
	},
	{
		path: '/RCIM-Geographic',
		component: Layout,
		children: [
			{
				path: '/RCIM-Geographic',
				component: () => import('@/views/RCIM-Geographic/index.vue'),
				name: 'GIS地理信息',
				meta: { title: 'GIS地理信息', icon: 'iconfont iconzongicon-51' }
			},
			{
				path: '/RCIM-SourceSpace',
				component: () => import('@/views/RCIM-SourceSpace/index.vue'),
				hidden: true,
				name: '源空间',
				meta: { title: '源空间', icon: 'iconfont iconmaijiabz' }
			}
		]
	},
	{
		path: '/RCIM-abnormalSupervision',
		component: Layout,
		children: [
			{
				path: '/RCIM-abnormalSupervision',
				component: () => import('@/views/RCIM-abnormalSupervision/index'),
				name: '异常督办',
				meta: { title: '异常督办', icon: 'iconfont iconmaijiabz' }
			}
		]
	},
	{
		path: '/RCIM-systemConfig',
		component: Layout,
		redirect: '/organization-config',
		meta: { title: '系统配置', icon: 'iconfont iconpeizhiguanli' },
		isChildren: true,
		children: [

			{
				path: '/organization-config',
				component: () => import('@/views/RCIM-systemConfig/organization-config'),
				name: '组织架构配置',
				meta: { title: '组织架构配置' }

			},
			{
				path: '/param-info',
				component: () => import('@/views/RCIM-systemConfig/param-info'),
				name: '参数信息',
				meta: { title: '参数信息' }
			}, {
				path: '/role-config',
				component: () => import('@/views/RCIM-systemConfig/role-config'),
				name: '角色配置',
				meta: { title: '角色配置' }
			},
			{
				path: '/account-info',
				component: () => import('@/views/RCIM-systemConfig/account-info'),
				name: '账号信息',
				meta: { title: '账号信息' }

			}, {
				path: '/template-info',
				component: () => import('@/views/RCIM-systemConfig/template-info'),
				name: '模板信息',
				meta: { title: '模板信息' }
			},
			{
				path: '/alarminfo-config',
				component: () => import('@/views/RCIM-systemConfig/alarminfo-config'),
				name: '异常监测配置',
				meta: { title: '异常监测配置' }
			},
			{
				path: '/alarmnotice-config',
				component: () => import('@/views/RCIM-systemConfig/alarmnotice-config'),
				name: '异常通知配置',
				meta: { title: '异常通知配置' }

			}
		]
	},

	{
		path: '/RCIM-statistics-declaration',
		component: Layout,
		redirect: '/source-declaration',
		meta: { title: '申报统计', icon: 'iconfont iconconfig-link-audit' },
		isChildren: true,
		children: [
			{
				path: '/source-declaration',
				component: () => import('@/views/RCIM-sourceDeclaration/index.vue'),
				name: '放射源申报',
				meta: { title: '放射源申报' }
			},
			{
				path: '/licence-declaration',
				component: () => import('@/views/RCIM-licenceDeclaration/index.vue'),
				name: '许可证申报',
				meta: { title: '许可证申报' }
			},
			{
				path: '/addandstorage-declaration',
				component: () => import('@/views/RCIM-addandstorageDeclaration/index.vue'),
				name: '源新增收贮申报',
				meta: { title: '源新增收贮申报' }
			},
			{
				path: '/source-statistics',
				component: () => import('@/views/RCIM-sourceStatistics/index.vue'),
				name: '放射源申报统计',
				meta: { title: '放射源申报统计' }
			},
			{
				path: '/licence-statistics',
				component: () => import('@/views/RCIM-licenceStatistics/index.vue'),
				name: '许可证申报统计',
				meta: { title: '许可证申报统计' }
			},
			{
				path: '/addandstorage-statistics',
				component: () => import('@/views/RCIM-addandstorageStatistics/index.vue'),
				name: '源新增收贮申报统计',
				meta: { title: '源新增收贮申报统计' }
			}

		]
	},
	{
		path: '/RCIM-archivesSearch',
		component: Layout,
		children: [
			{
				path: '/archivesQuery',
				component: () => import('@/views/RCIM-archives-search/index.vue'),
				name: '档案查询',
				meta: { title: '档案查询', icon: 'iconfont iconzongicon' }
			}
		]
	},
	{
		path: '/RCIM-archives',
		component: Layout,
		children: [
			{
				path: '/archives',
				component: () => import('@/views/RCIM-archives/index.vue'),
				name: '档案管理',
				meta: { title: '档案管理', icon: 'iconfont iconzongicon' }
			}
		]
	},
	// {
	// 	path: '/RCIM-source-statistics',
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: '/source-statistics',
	// 			component: () => import('@/views/RCIM-sourceStatistics/index.vue'),
	// 			name: '放射源申报统计',
	// 			meta: { title: '放射源申报统计', icon: 'iconfont iconzongicon' }
	// 		}
	// 	]
	// },
	// {
	// 	path: '/RCIM-licence-declaration',
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: '/licence-declaration',
	// 			component: () => import('@/views/RCIM-licenceDeclaration/index.vue'),
	// 			name: '许可证申报',
	// 			meta: { title: '许可证申报', icon: 'iconfont iconzongicon' }
	// 		}
	// 	]
	// },
	// {
	// 	path: '/RCIM-licence-statistics',
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: '/licence-statistics',
	// 			component: () => import('@/views/RCIM-licenceStatistics/index.vue'),
	// 			name: '许可证申报统计',
	// 			meta: { title: '许可证申报统计', icon: 'iconfont iconzongicon' }
	// 		}
	// 	]
	// },
	// {
	// 	path: '/RCIM-addandstorage-declaration',
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: '/addandstorage-declaration',
	// 			component: () => import('@/views/RCIM-addandstorageDeclaration/index.vue'),
	// 			name: '源新增收贮申报',
	// 			meta: { title: '源新增收贮申报', icon: 'iconfont iconzongicon' }
	// 		}
	// 	]
	// },
	// {
	// 	path: '/RCIM-addandstorage-statistics',
	// 	component: Layout,
	// 	children: [
	// 		{
	// 			path: '/addandstorage-statistics',
	// 			component: () => import('@/views/RCIM-addandstorageStatistics/index.vue'),
	// 			name: '源新增收贮申报统计',
	// 			meta: { title: '源新增收贮申报统计', icon: 'iconfont iconzongicon' }
	// 		}
	// 	]
	// },
	// 404 page must be placed at the end !!!
	{ path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({ y: 0 }),
	routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router
